clear all

***************************************************************************
* Table IA2. Estimation Using Data Collapsed at the Individual Level
***************************************************************************

* NLSY
use "nlsy_pseudo", clear
bysort id: egen es = mean(es_pct)
by id: egen fin_distress_max = max(fin_distress)
by id: egen age_avg = mean(age)
by id: egen married_avg = mean(married)
by id: egen hlthy_avg = mean(hlthy)
by id: egen inctot_avg = mean(inctot)
by id: egen own_home_avg = mean(own_home)
by id: keep if _n == 1
reghdfe fin_distress_max es age_avg college married_avg-own_home_avg, a(male) vce(r)

* HRS
use "hrs_pseudo", clear
bysort id: egen es = mean(es_pct)
by id: egen fin_distress_max = max(fin_distress)
by id: egen age_avg = mean(age)
by id: egen married_avg = mean(married)
by id: egen hlthy_avg = mean(hlthy)
by id: egen inctot_avg = mean(inctot)
by id: egen own_home_avg = mean(own_home)
by id: keep if _n == 1
reghdfe fin_distress_max es age_avg college married_avg-own_home_avg, a(male) vce(r)

* HILDA
use "hilda_pseudo", clear
bysort id: egen es = mean(es_pct)
by id: egen late_house_max = max(late_house)
by id: egen late_bills_max = max(late_bills)
by id: egen age_avg = mean(age)
by id: egen college_max = max(college)
by id: egen married_avg = mean(married)
by id: egen hlthy_avg = mean(hlthy)
by id: egen inctot_avg = mean(inctot)
by id: egen own_home_avg = mean(own_home)
by id: keep if _n == 1
reghdfe late_house_max es age_avg-own_home_avg, a(male) vce(r)
reghdfe late_bills_max es age_avg-own_home_avg, a(male) vce(r)
